/**
 * MemSessionImpl.java
 * Copyright © 2015-3015, 杭州泊享网络科技有限公司
 * 
 * @author Liu Tao
 * @create 2013-8-9
 */
package com.pshare.session.impl.memcache;

import com.pshare.session.SessionFactory;
import com.pshare.session.impl.DefaultSessionImpl;


/**
 * 基于MemCached缓存机制的会话对象实现类
 */
public class MemSessionImpl extends DefaultSessionImpl {

    private static final long serialVersionUID = 1305088632965253298L;

    public MemSessionImpl(String id, SessionFactory factory) {
        super(id, factory);
    }

    @Override
    public void setAttribute(String key, Object value) {
        super.setAttribute(key, value);
        this.store();
    }

    @Override
    public void update(long time) {
        super.update(time);
        this.store();
    }

    private void store() {
        getFactory().put(this);
    }
}
